package cn.yuanqiao.web.controller.archive.supervision;

import cn.yuanqiao.archive.supervision.domain.YqIssuedNotice;
import cn.yuanqiao.archive.supervision.service.AddAnnualInspectionMaterialsService;
import cn.yuanqiao.common.core.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.core.page.TableDataInfo;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * 下级单位添加年检材料
 *
 * @author : 庸人一个
 * @create : 2024/3/13 15:24
 */
@RestController
@RequestMapping("/archive/addannu")
public class AddAnnualInspectionMaterialsController extends BaseController {

    @Autowired
    private AddAnnualInspectionMaterialsService service;


    //分页条件查询
    @PostMapping("/findPage")
    public TableDataInfo findPage(@RequestBody YqIssuedNotice issuedNotice) {
        startPage();
        List<YqIssuedNotice> list = service.findPage(issuedNotice);
        if (CollectionUtils.isEmpty(list)) {
            list = new ArrayList<>();
        }
        return getDataTable(list);
    }

    //修改状态
    @GetMapping("/updateStatus")
    public AjaxResult updateStatus(Long id, String type) {
        return service.updateStatus(id, type);
    }

    //查看通知及查看退回原因
    @GetMapping("/findNotice")
    public AjaxResult findNotice(Long id) {
        return AjaxResult.success(service.findNotice(id));
    }

    //提醒上报
    @GetMapping("/remind")
    public AjaxResult remind(String tenantCode) {
        service.remind(tenantCode);
        return AjaxResult.success();
    }


    //按照id修改
    @PutMapping("/updateById")
    public AjaxResult updateById(@RequestBody YqIssuedNotice issuedNotice) {
        return service.updateById(issuedNotice);
    }

    //统计
    @GetMapping("/statistics")
    public AjaxResult statistics() {
        return success(service.statistics());
    }
}
